package com.heima.movement.controller;


import com.heima.models.common.Result;
import com.heima.models.movement.dtos.MovementAddDto;
import com.heima.movement.service.MovementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Generated;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 黑马程序员
 * @since 2023-07-04
 */
@RestController
@RequestMapping("/movement")
public class MovementController {
    @Autowired
    private MovementService movementService;

    @PostMapping
    public Result addMovement(@RequestBody MovementAddDto dto) {
        return movementService.addMovement(dto);
    }

    @GetMapping("/list")
    public Result listMovement(Integer type,
                               Integer page,
                               Integer pageSize,
                               Double longitude,
                               Double latitude) {

        // type = 1，去查周边的动态（不做分页，只查最近的30条）
        if (type == 1) {
            return movementService.listMovementByLocation(longitude, latitude);
        }

        // type = 2，去查好友的动态（做分页）
        return Result.success("");
    }
}

